import time
import ddt

from Base.BaseSetings import TestData_dir
from Base.PublicFunction import readTable
# from WoniuBossPOM.HumanManagement_POM_Sun import WoniuBossObj
from WoniuBossPOM.All_Management_POM import All_Mamagement



class WoniuBoss():
    def __init__(self):
        self.obj =  All_Mamagement()

    # def closebrower(self):
    #     self.obj.close()

    def human_mangement_creatstaff(self,kwargs):
        time.sleep(6)
        self.obj.get_humanmange().click() #点击‘人事管理’
        self.obj.get_staffinfo().click() #点击‘员工信息’
        self.obj.get_creatbutton()[1].click()  # 点击新增
        time.sleep(3)
        self.obj.get_creatinfo(kwargs.get('info'))  #新增员工-区域
        time.sleep(3)
        self.obj.get_creatempment(kwargs.get('empment')) #部门
        self.obj.get_position()[1].send_keys(kwargs.get('positon')) #职位
        time.sleep(2)
        self.obj.get_name()[1].send_keys(kwargs.get('name')) #输入姓名
        time.sleep(2)
        self.obj.get_workid()[1].send_keys(kwargs.get('workid')) #输入工号
        self.obj.get_saving().click() #点击保存
        time.sleep(3)
        self.obj.get_determine().click() #点击确定
        time.sleep(3)
        self.obj.get_staffname().send_keys(kwargs.get('name'))
        self.obj.get_clicks().click()
        time.sleep(2)
        tableobj = self.obj.get_table()
        result= readTable(tableobj)

        return result

    def human_mangement_querystaff(self,region,dep,status,name):
        time.sleep(5)
        self.obj.get_humanmange().click() #点击‘人事管理’
        self.obj.get_staffinfo().click() #点击‘员工信息’
        self.obj.get_region(region)
        self.obj.get_dep(dep)
        self.obj.get_status(status)
        self.obj.get_staffname().click()
        self.obj.get_staffname().send_keys(name)
        self.obj.get_clicks().click()
        time.sleep(2)
        tableobj = self.obj.get_table()
        return readTable(tableobj)



if __name__ == '__main__':
    wn = WoniuBoss()
    # kwargss=[{'info':'成都','empment':'教学部','positon':'讲师','name':'陈晨','workid':'WNCD100'},
    #         {'info': '成都', 'empment': '咨询部', 'positon': '咨询师', 'name': '刘欣', 'workid': 'WNCD101'}]
    # wn.human_mangement_creatstaff(kwargss)

    a = wn.human_mangement_querystaff('全部','全部','全部','张莉')
    print(a)
